package com.aruba.mvvmapplication.di

import android.app.Application
import androidx.room.Room
import com.aruba.mvvmapplication.database.AppDatabase
import com.aruba.mvvmapplication.database.MovieDao
import com.aruba.mvvmapplication.mapper.MovieEntity2ItemModelMapper
import com.aruba.mvvmapplication.remote.MovieService
import com.aruba.mvvmapplication.repository.MovieRepositoryImpl
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityComponent
import dagger.hilt.android.components.ApplicationComponent
import dagger.hilt.android.scopes.ActivityScoped
import javax.inject.Singleton

/**
 * Created by aruba on 2021/9/24.
 */
@InstallIn(ActivityComponent::class)
@Module
object RepositoryModule {

    @ActivityScoped
    @Provides
    fun provideMovieRepository(
        api: MovieService,
        appDatabase: AppDatabase
    ): MovieRepositoryImpl {
        return MovieRepositoryImpl(api, appDatabase, MovieEntity2ItemModelMapper())
    }

}